import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class JdbcPreparedstatementExample {

  static private final String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
  static private final String connection = "jdbc:odbc:emp";

  public static void main(String args[]) {

  Connection con = null;
  PreparedStatement pst = null;
  ResultSet rs = null;

  try {

  Class.forName(driver);
  con = DriverManager.getConnection(connection);

  String sql =
  "select * from Employees where FirstName " + "in(?,?,?)";
  pst = con.prepareStatement(sql);

  pst.setString(1, "harsh");
  pst.setString(2, "sagar");
  pst.setString(3, "jalaj");

  rs = pst.executeQuery();
  System.out.println("EmployeeID\tFirstName\tLastName");
  while (rs.next()) {
  System.out.print("  "+rs.getString(1));
  System.out.print("\t\t"+rs.getString(2));
  System.out.println("\t\t"+rs.getString(3));
  }
  
  } catch (Exception e) {
  System.out.println(e);
  }
  }
} 
